#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
   @Author: 叶建伟
   @Email: yejw46507@hundsun.com
   @Time: 2023/7/4 14:50
   @File: clientInfo.py
"""
import datetime
from random import choice

from faker import Faker

from DataTest.sqlmontage import randomInfo
from DataTest.tabledata.dataTest import fake

bank_list = {''}
#'50'基金成立,'51',基金终止
bussine_flag_list = ['01','02','03','04','05企业日志查询','06','07','10','11','12','13','17','81','82','83','84','85','86','87','88','89']
#学历：'01'博士 ,'02'硕士,'03'学士,'04'大专,'05企业日志查询'中专,'06'高中,'07'高中及以下,'99'其他
education_code_list = ['01','02','03','04','05企业日志查询','06','07','99']
#职业代码 37学生 99其他
occupation_code_list = ['01','02','03','04','05企业日志查询','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','99']

def client_info():
    '''
    利用fake工具生成个人信息
    '''
    client_list = {}
    fake = Faker(locale='zh_CN')
    daytime_client_name = fake.name()  # 日间客户名称
    daytime_id_no = fake.ssn()  # 日间客户身份证
    client_name = fake.name() #姓名
    client_full_name = client_name #全名
    contact_address = fake.address().split(' ')[0] #联系地址
    birth_date = fake.date(pattern = '%Y%m%d')#生日
    email_address = fake.email()#邮箱
    id_no = fake.ssn() #身份证
    telephone_number = fake.phone_number()  #电话号码
    cellphone_number = fake.phone_number()  #移动电话号码
    nationality_code = fake.country_code()  #国籍代码
    occupation_code = choice(occupation_code_list)  #职业代码
    # industry_code =  #行业代码
    education_code = choice(education_code_list)
    business_flag = choice(['01','02','03']) #业务标识'01'认购,'02'申购,'03'赎回
    work_unit = fake.company() #工作单位
    work_unit_tel = fake.phone_number() #工作单位电话
    work_unit_address = fake.address().split(' ')[0] #工作单位地址
    addr_zip = fake.address().split(' ')
    resident_address = addr_zip[0]  #居住地址
    zip_code = addr_zip[1]  #邮政编码
    occur_date = fake.date_between(start_date='-1y', end_date='today').strftime("%Y%m%d") #发生日期
    fund_account = 'hsjj'+str(fake.random_number(digits=8))+str(fake.random_number(digits=6)) #基金账户
    fund_acc_status = '1' # 基金账户状态
    trade_status = '1' # 交易状态
    trade_account = 'jyzh'+str(fake.random_number(digits=8))+str(fake.random_number(digits=6))  # 交易账户
    apply_date = fake.date_between(start_date='-1y', end_date='today').strftime("%Y%m%d") #申请日期

    apply_no = 'zhsq'+str(fake.random_number(digits=8))+str(fake.random_number(digits=6)) #账号申请编号
    confirm_no ='qrbh'+str(fake.random_number(digits=8))+str(fake.random_number(digits=6))   #账号确认编号
    confirm_date = fake.date_between(start_date='-1y', end_date='today').strftime("%Y%m%d")  #账号确认时间
    serial_no = fake.uuid4()[:-4]  #序列号
    uuid_code = fake.uuid4()[:-4]#通用唯一识别码
    open_bank_name = fake.credit_card_provider(card_type=None)  #开户银行名称
    bank_account = fake.credit_card_number(card_type=None)  #银行卡号
    client_list.update({'client_name':client_name})
    client_list.update({'client_full_name':client_full_name})
    client_list.update({'contact_address':contact_address})
    client_list.update({'birth_date':birth_date})
    client_list.update({'email_address':email_address})
    client_list.update({'id_no':id_no})
    client_list.update({'nationality_code':nationality_code})
    client_list.update({'zip_code':zip_code})
    client_list.update({'telephone_number':telephone_number})
    client_list.update({'cellphone_number':cellphone_number})
    client_list.update({'work_unit':work_unit})
    client_list.update({'work_unit_tel':work_unit_tel})
    client_list.update({'work_unit_address':work_unit_address})
    client_list.update({'resident_address':resident_address})
    client_list.update({'email_address':email_address})
    client_list.update({'occur_date':occur_date})
    client_list.update({'apply_date':apply_date})
    client_list.update({'fund_account':fund_account})
    client_list.update({'open_bank_name':open_bank_name})
    client_list.update({'bank_account':bank_account})
    client_list.update({'business_flag':business_flag})
    client_list.update({'fund_acc_status':fund_acc_status})
    client_list.update({'trade_status':trade_status})
    client_list.update({'education_code':education_code})
    client_list.update({'occupation_code':occupation_code})
    client_list.update({'trade_account':trade_account})
    client_list.update({'apply_no':apply_no})
    client_list.update({'confirm_no': confirm_no})
    client_list.update({'confirm_date': confirm_date})
    client_list.update({'serial_no': serial_no})
    client_list.update({'uuid_code': uuid_code})
    client_list.update({'daytime_client_name': daytime_client_name})
    client_list.update({'daytime_id_no': daytime_id_no})
    print(client_list)
    return client_list



def client_info_list():
    client_list = {}
    client_list.update(randomInfo.generate_info())
    contact_address = randomInfo.get_address().split(' ')[0] #联系地址
    occupation_code = choice(occupation_code_list)  #职业代码
    nationality_code = 'CHN'  # 国籍代码
    # industry_code =  #行业代码
    education_code = choice(education_code_list) #学历
    business_flag = choice(['01','02','03']) #业务标识'01'认购,'02'申购,'03'赎回
    work_unit = randomInfo.get_company() #工作单位
    work_unit_tel = randomInfo.get_random_cell_phone() #工作单位电话
    work_unit_address = randomInfo.get_address().split(' ')[0] #工作单位地址
    addr_zip = randomInfo.get_address().split(' ')
    resident_address = addr_zip[0]  #居住地址
    zip_code = addr_zip[1]  #邮政编码
    occur_date = randomInfo.get_random_date() #发生日期
    fund_account = 'hsjj' + str(randomInfo.get_random_number(8)) + str(randomInfo.get_random_number(6)) #基金账户
    fund_acc_status = '1' # 基金账户状态
    trade_status = '1' # 交易状态
    trade_account = 'hsjy' + str(randomInfo.get_random_number(8)) + str(randomInfo.get_random_number(6))  # 交易账户
    apply_date = randomInfo.get_random_date() #申请日期

    # apply_no = fake.date_between(start_date='-2y', end_date='today').strftime("%Y%m%d") #账号申请编号
    # confirm_no =   #账号确认编号
    # comfirm_date =   #账号确认时间
    # serial_no = fake  #序列号
    # uuid_code = fake.uuid4()#通用唯一识别码
    # open_bank_name = fake.credit_card_provider(card_type=None)  #开户银行名称
    # bank_account = fake.credit_card_number(card_type=None)  #银行卡号
    # client_list.update({'client_name':client_name})
    # client_list.update({'client_full_name':client_full_name})
    client_list.update({'contact_address':contact_address})
    client_list.update({'nationality_code':nationality_code})
    client_list.update({'zip_code':zip_code})
    client_list.update({'work_unit':work_unit})
    client_list.update({'work_unit_tel':work_unit_tel})
    client_list.update({'work_unit_address':work_unit_address})
    client_list.update({'resident_address':resident_address})
    client_list.update({'occur_date':occur_date})
    client_list.update({'apply_date':apply_date})
    client_list.update({'fund_account':fund_account})
    client_list.update({'business_flag':business_flag})
    client_list.update({'fund_acc_status':fund_acc_status})
    client_list.update({'trade_status':trade_status})
    client_list.update({'education_code':education_code})
    client_list.update({'occupation_code':occupation_code})
    client_list.update({'trade_account':trade_account})
    # client_list.update({'open_bank_name':open_bank_name})
    # client_list.update({'bank_account':bank_account})
    # client_list.update({'uuid_code':uuid_code})
    # print(client_list)
    return client_list

def client_info_srm():
    client_list = {}
    client_list.update(randomInfo.generate_info())
    contact_address = randomInfo.get_address().split(' ')[0] #联系地址
    nationality_code = 'CHN'  # 国籍代码
    apply_date = randomInfo.get_random_date() #申请日期
    open_date = randomInfo.get_random_date()
    financial_organ_code = randomInfo.get_random_number(14)
    close_date = randomInfo.get_overdue_date()
    client_list.update({'close_date': close_date})
    client_list.update({'financial_organ_code': financial_organ_code})
    client_list.update({'living_address1':contact_address})
    client_list.update({'nationality_code':nationality_code})
    client_list.update({'open_date_str':str(apply_date)})
    client_list.update({'open_date_str': str(open_date)})
    return client_list

def cst_unit_list():
    client_list = {}
    client_list.update(randomInfo.generate_info())
    nationality_code = 'CHN'  # 国籍代码
    contact_address = randomInfo.get_address().split(' ')[0] #联系地址
    industry_code = choice(['01','02','03','04','05企业日志查询','06','07','08','09'])  # 行业代码
    industry_name = choice(['学生', '公务员', '国企员工', '普通工人', '教师', '医生', 'IT从业人员', '自由职业者', '外企员工'])  # 行业代码
    currency_code= 'CHN'
    org_code = randomInfo.get_random_number(14)
    apply_date = randomInfo.get_random_date() #申请日期
    close_date = randomInfo.get_overdue_date()
    id_no = randomInfo.random_credit_code()
    id_end_date_str = randomInfo.get_overdue_date()
    financial_organ_code = randomInfo.get_random_number(14)
    client_list.update({'financial_organ_code': financial_organ_code})
    client_list.update({'id_end_date_str': id_end_date_str})
    client_list.update({'currency_code': currency_code})
    client_list.update({'org_code': org_code})
    client_list.update({'industry_code': industry_code})
    client_list.update({'industry_name': industry_name})
    client_list.update({'living_address1':contact_address})
    client_list.update({'nationality_code':nationality_code})
    client_list.update({'open_date_str':str(apply_date)})
    client_list.update({'apply_date':apply_date})
    client_list.update({'id_no':id_no})
    client_list.update({'close_date_str':str(close_date)})
    data = randomInfo.generate_info()
    client_list.update({'legp_name': data.get('client_name')})
    client_list.update({'legp_id_no': data.get('id_no')})
    client_list.update({'legp_id_end_date_str': data.get('id_end_date')})
    data1 = randomInfo.generate_info()
    client_list.update({'ctrl_shareholder_name': data1.get('client_name')})
    client_list.update({'ctrl_shareholder_id_no': data1.get('id_no')})
    client_list.update({'ctrl_shareholder_id_end_date_str': data1.get('id_end_date')})
    data2 = randomInfo.generate_info()
    client_list.update({'transactor_name': data2.get('client_name')})
    client_list.update({'transactor_id_no': data2.get('id_no')})
    client_list.update({'transactor_id_end_date_str': data2.get('id_end_date')})

    # client_list.update({'open_bank_name':open_bank_name})
    # client_list.update({'bank_account':bank_account})
    # client_list.update({'uuid_code':uuid_code})
    # print(client_list)
    return client_list

def product_acc_list():
    client_list = {}
    client_list.update(randomInfo.generate_info())
    contact_address = randomInfo.get_address().split(' ')[0] #联系地址
    industry_code = choice(['01', '02', '03', '04', '05企业日志查询', '06', '07', '08', '09'])  # 行业代码
    industry_name = choice(['学生', '公务员', '国企员工', '普通工人', '教师', '医生', 'IT从业人员', '自由职业者', '外企员工'])  # 行业代码
    nationality_code = 'CHN'  # 国籍代码
    occur_date = randomInfo.get_random_date() #发生日期
    apply_date = randomInfo.get_random_date() #申请日期
    close_date = randomInfo.get_overdue_date()
    financial_organ_code = randomInfo.get_random_number(14)
    client_list.update({'financial_organ_code': financial_organ_code})
    client_list.update({'industry_code': industry_code})
    client_list.update({'industry_name': industry_name})
    client_list.update({'living_address1':contact_address})
    client_list.update({'nationality_code':nationality_code})
    client_list.update({'init_date':occur_date})
    client_list.update({'open_date_str':str(apply_date)})
    client_list.update({'apply_date':apply_date})
    client_list.update({'close_date_str':str(close_date)})
    data = randomInfo.generate_info()
    client_list.update({'legp_name': data.get('client_name')})
    client_list.update({'legp_id_no': data.get('id_no')})
    client_list.update({'legp_id_end_date_str': data.get('id_end_date')})
    data1 = randomInfo.generate_info()
    client_list.update({'ctrl_shareholder_name': data1.get('client_name')})
    client_list.update({'ctrl_shareholder_id_no': data1.get('id_no')})
    client_list.update({'ctrl_shareholder_id_end_date_str': data1.get('id_end_date')})
    data2 = randomInfo.generate_info()
    client_list.update({'transactor_name': data2.get('client_name')})
    client_list.update({'transactor_id_no': data2.get('id_no')})
    client_list.update({'transactor_id_end_date_str': data2.get('id_end_date')})
    return client_list



def securities_acc_list():
    client_list = {}
    financial_organ_code = randomInfo.get_random_number(14)
    acc_type_code= choice(occupation_code_list)  #职业代码
    acc_stat_code= financial_organ_code
    stock_account = randomInfo.get_random_number(8)
    account_flag = choice(['01','02','03'])
    open_way = '1' # 基金账户状态
    apply_date = randomInfo.get_random_date() #申请日期
    occur_date = randomInfo.get_random_date() #发生日期
    client_list.update({'financial_organ_code':financial_organ_code})
    client_list.update({'acc_type_code':acc_type_code})
    client_list.update({'acc_stat_code':acc_stat_code})
    client_list.update({'stock_account':stock_account})
    client_list.update({'account_flag':account_flag})
    client_list.update({'open_way':open_way})
    client_list.update({'open_date_str':str(apply_date)})
    client_list.update({'apply_date':apply_date})
    client_list.update({'init_date':occur_date})
    return client_list

def capital_acc_list():
    client_list = {}
    financial_organ_code = randomInfo.get_random_number(14)
    stock_account = randomInfo.get_random_number(8)
    account_flag = choice(['11','12','13'])
    open_way = '11' # 基金账户状态
    occur_date = randomInfo.get_random_date() #发生日期
    bank_account = fake.credit_card_number(card_type=None)  # 银行卡号
    client_list.update({'financial_organ_code':financial_organ_code})

    client_list.update({'stock_account':stock_account})
    client_list.update({'account_flag':account_flag})
    client_list.update({'open_way':open_way})
    client_list.update({'open_date_str':str(occur_date)})
    client_list.update({'init_date':occur_date})
    client_list.update({'bank_account': bank_account})
    return client_list

def risk_new_list():
    client_list = {}
    financial_organ_code = randomInfo.get_random_number(14)
    occur_date = randomInfo.get_random_date() #发生日期
    client_list.update({'financial_organ_code':financial_organ_code})
    client_list.update({'init_date':occur_date})
    return client_list

def risk_his_list():
    client_list = {}
    financial_organ_code = randomInfo.get_random_number(3)
    occur_date = randomInfo.get_random_date() #发生日期
    client_list.update({'init_date': occur_date})
    client_list.update({'financial_organ_code':financial_organ_code})

    return client_list

def settle_type():
    client_list = {}
    report_institution_no= randomInfo.get_random_number(6)
    client_list.update({'report_institution_no':report_institution_no})
    return client_list

def bank_txn_list():
    client_list = {}
    client_list.update(randomInfo.generate_info())
    apply_date = randomInfo.get_random_date() #申请日期
    uuid_code = randomInfo.random_credit_code()
    trade_amount = randomInfo.get_random_number(7)
    # trade_date_str = randomInfo.get_random_date()
    bank_account = fake.credit_card_number(card_type=None)  # 银行卡号
    trade_way = choice(['11','12','13','14','15','16','17'])
    jour_num = randomInfo.get_random_number(8)
    imei_code = randomInfo.get_random_number(7)
    payment_flag = choice(['10','11'])
    client_list.update({'apply_date':apply_date})
    client_list.update({'uuid_code':uuid_code})
    client_list.update({'trade_amount':trade_amount})
    client_list.update({'trade_way': trade_way})
    client_list.update({'bank_account': bank_account})
    client_list.update({'jour_num': jour_num})
    client_list.update({'imei_code': imei_code})
    client_list.update({'uuid_code': uuid_code})
    client_list.update({'payment_flag': payment_flag})
    return client_list

def multi_bank_txn_list():
    client_list = {}
    uuid_code = randomInfo.random_credit_code()
    capital_account = randomInfo.get_random_number(7)
    client_list.update({'trade_amount':capital_account})
    current_balance = randomInfo.get_random_number(8)
    jour_num = randomInfo.get_random_number(8)
    client_list.update({'current_balance': current_balance})
    client_list.update({'jour_num': jour_num})
    client_list.update({'uuid_code': uuid_code})
    return client_list

def deliver_list():
    client_list = {}
    uuid_code = randomInfo.random_credit_code()
    capital_account = randomInfo.get_random_number(7)
    entrust_no = randomInfo.get_random_number(9)
    imei_code = randomInfo.get_random_number(7)
    jour_num = randomInfo.get_random_number(8)
    client_list.update({'trade_amount':capital_account})
    client_list.update({'entrust_no': entrust_no})
    client_list.update({'imei_code': imei_code})
    client_list.update({'uuid_code': uuid_code})
    client_list.update({'jour_num': jour_num})
    return client_list


def sus_report_list():
    client_list = {}
    capital_account = randomInfo.get_random_number(7)
    client_list.update({'capital_account_list': capital_account})
    return client_list

def tran_his_list():
    client_list = {}
    capital_account = randomInfo.get_random_number(7)
    financial_organ_code = randomInfo.get_random_number(3)
    client_list.update({'financial_organ_code': financial_organ_code})
    client_list.update({'capital_account': capital_account})
    client_list.update({'stock_account': capital_account})
    return client_list

def bnf_info_list():
    client_list = {}
    data1= randomInfo.generate_info()
    capital_account = randomInfo.get_random_number(7)
    financial_organ_code = randomInfo.get_random_number(3)
    occur_date = randomInfo.get_random_date()  # 发生日期
    work_unit_address = randomInfo.get_address().split(' ')[0]  # 工作单位地址
    client_list.update({'init_date': occur_date})
    client_list.update({'financial_organ_code': financial_organ_code})
    client_list.update({'capital_account': capital_account})
    client_list.update({'benefit_name': data1.get('client_name')})
    client_list.update({'benefit_address': work_unit_address})
    client_list.update({'benefit_id_type': '01'})
    client_list.update({'benefit_id_no': data1.get('id_no')})
    client_list.update({'benefit_id_end_date_str': data1.get('id_end_date')})

    return client_list

if __name__ == '__main__':
    # for i in range(0,10):
    #     client_info()
    #     print(datetime.datetime.now())

    print(datetime.datetime.now())
    # list = []
    # fake = Faker(locale='zh_CN')
    for i in range(10):
        print(client_info())
    print(datetime.datetime.now())
    # print(list)
    # print(len(list))
